package com.societyGames.flashForms
{
import com.societyGames.system.EventObject;

import flash.display.DisplayObject;
import flash.events.Event;
import flash.events.EventDispatcher;

public class TabItem extends EventDispatcher
{
  private var _headerButton:FourStateButton;
  private var _content:DisplayObject;
  private var _headerClickedEventObject:EventObject;

  public function TabItem(headerButton:FourStateButton, content:DisplayObject)
  {
    this._headerClickedEventObject = new EventObject(this, "CLICKED", Event);
    this._headerButton = headerButton;
    this._content = content;

    this._headerButton.buttonClickEventObject.addEventListener(headerClickedHandler);
  }

  public function get headerButton():DisplayObject
  {
    return this._headerButton;
  }

  public function select():void
  {
    this._headerButton.enabled = false;
  }

  public function deselect():void
  {
    this._headerButton.enabled = true;
  }

  public function get content():DisplayObject
  {
    return this._content;
  }

  public function get headerClickedEventObject():EventObject
  {
    return this._headerClickedEventObject;
  }

  private function headerClickedHandler(event:Event):void
  {
    this._headerClickedEventObject.dispatchEvent();
  }
}
}